<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      padding: 10px;
    }
  </style>
</head>
<body>
  <div>
    生日：<input type="date" name="bday" id=""> <button data-type="date" class="show-value">获取值</button> <span data-type="date"></span>
  </div>
  <div>
    当前时间: <input type="datetime" name="now" id=""> <button data-type="datetime" class="show-value">获取值</button> <span data-type="datetime"></span>
  </div>
  <div>
    事件发生的具体时间: <input type="datetime-local" name="" id=""> <button data-type="datetime-local" class="show-value">获取值</button> <span data-type="datetime-local"></span>
  </div>
  <div>
    选择时间：<input type="time"> <button data-type="time" class="show-value">获取值</button> <span data-type="time"></span>
  </div>
  <div>
    出生年月：<input type="month" name="bdaymonth"> <button data-type="month" class="show-value">获取值</button> <span data-type="month"></span>
  </div>
  <div>
    当前是今年的第几周：<input type="week" name="week-year"> <button data-type="week" class="show-value">获取值</button> <span data-type="week"></span>
  </div>
  <div>
    <input type="search" name="" id="">
  </div>
  <script>
    let btns = document.querySelectorAll('.show-value');
    Array.from(btns).forEach((e, i) => {
      let type = e.dataset.type;
      e.onclick = function() {
        let value = document.querySelector(`input[type=${type}]`).value;
        document.querySelector(`span[data-type=${type}]`).innerText = value;
      }
      
    });
  </script>
</body>
</html>